class Step{
    get step(){
        return this._step;
    }
    set step(value){
        this._step = value;
        console.info(this._step);
        // set left nav bar active
        this.showContent();
    }
    constructor() {
        this.initStepButton();
        this.clickStep();
    }
    showContent(){
        $(".s-content").css("display", "none");
        //$("div[aria-level='step" + this.step + "']").removeClass('hidden');
        $("div[aria-level='step" + this.step + "']").fadeIn();
        if (this.step == 1){
            $(".back").addClass("invisible");
        } else {
            $(".back").removeClass("invisible");
        }
        if (this.step >= 1 && this.step < $(".step").length){
            $(".next").removeClass("invisible");
        } else {
            $(".next").addClass("invisible");
        }
        // active the left nav
        $(".step").removeClass("s-active");
        var that = this;
        $(".step").each(function(){
            if($(this).children('span.s-num').first().text() <= that.step) {
                $(this).addClass('s-active');
            }
        })
    }
    printStep(){
        console.info(this.step);
    }
    // 导航栏点击事件
    clickStep(){
        var that = this;
        $(".step").click(function(){
            $(this).nextAll().removeClass('s-active');
            $(this).addClass('s-active');
            $(this).prevAll().addClass('s-active');
            that.step = $(this).children('span.s-num').first().text();
            window.location.href = window.location.pathname + "#step" + that.step;
        });
        $(".next").click(function(){
            that.step++;
            window.location.href = window.location.pathname + "#step" + that.step;
        });
        $(".back").click(function(){
            that.step--;
            window.location.href = window.location.pathname + "#step" + that.step;
        });
    }
    // init back / next button when open page
    initStepButton(){
        if (window.location.href.indexOf("step") == -1 || window.location.href.indexOf("step1") != -1) {
            this.step = 1;
            $(".back").addClass("invisible");
        } else {
            this.step = window.location.href.substr(window.location.href.indexOf("step") + 4, 1);
            $(".back").removeClass("invisible");
        }
    }
}
var stepObj = new Step();